<template>
  <div id="app" v-bind:style="appDivStyle">
      <div class="context" ref="context">
           <div class="queryBox" ref="queryBox">
                <el-form :model="formQueryCondition"
                         ref="form" size="mini">
                         <el-row>
                             <!-- 标签名称 -->
                             <el-col :span="5">
                                 <el-form-item :label="$t('tagManage.queryLabel.tagName')"
                                    :label-width="queryformLabelWidth">
                                        <el-input v-model.trim="formQueryCondition.tagName.val" class="queryItemStyle" clearable
                                                :placeholder="$t('tagManage.queryLabel.placeholderTagName')"></el-input>
                                </el-form-item>
                             </el-col>
                             <!-- 上线状态 -->
                             <el-col :span="5" :offset="1">
                                 <el-form-item :label="$t('tagManage.queryLabel.onlineState')"   :label-width="queryformLabelWidth">
                                    <el-select v-model="formQueryCondition.state.val" class="queryItemStyle">
                                    <el-option :label="$t('tagManage.label.all')" value=""></el-option>
                                    <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText" v-for="drug in enables"></el-option>
                                    <!-- <el-option :label="$t('tagManage.label.online')" value="Online"></el-option>
                                    <el-option :label="$t('tagManage.label.offline')" value="Offline"></el-option> -->
                                    </el-select>
                                </el-form-item>
                             </el-col>
                             <!-- 下发状态 -->
                             <el-col :span="5" :offset="1">
                                 <el-form-item :label="$t('tagManage.queryLabel.sendtoState')"   :label-width="queryformLabelWidth">
                                    <el-select v-model="formQueryCondition.sendtoState.val" class="queryItemStyle">
                                      <el-option :label="$t('tagManage.label.all')" value=""></el-option>
                                      <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText" v-for="drug in sendtoStates"></el-option>
                                    </el-select>
                                </el-form-item>
                             </el-col>
                             <el-col :span="5" :offset="1">
                                 <el-form-item :label="$t('tagManage.queryLabel.status')"   :label-width="queryformLabelWidth">
                                    <el-select v-model="formQueryCondition.isEnable.val" class="queryItemStyle">
                                    <el-option :label="$t('tagManage.label.all')" value=""></el-option>
                                    <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText" v-for="drug in isEnables"></el-option>
                                    <!-- <el-option :label="$t('tagManage.label.online')" value="Online"></el-option>
                                    <el-option :label="$t('tagManage.label.offline')" value="Offline"></el-option> -->
                                    </el-select>
                                </el-form-item>
                             </el-col>
                         </el-row>
                         <el-row>
                             <el-col :span="24">
                                 <div style="text-align:right">
                                    <el-form-item>
                                        <!-- 新增 -->
                                        <el-button v-permission="{menuCode:menuCode,resourceCode:'saveBtnText'}" type="primary"  @click="onNew('saveBtnText')">{{ $t('btnText.newBtnText') }}</el-button>
                                    <!-- </el-form-item> -->
                                    <!-- <el-form-item> -->
                                        <!-- 导入 -->
                                        <el-button v-permission="{menuCode:menuCode,resourceCode:'ImportBtnText'}" type="primary" @click="openUploadDlg('ImportBtnText')" icon="el-icon-upload2">{{ $t('tagManage.btnText.importBtnText') }}</el-button>
                                    <!-- </el-form-item> -->
                                    <!--导入模板下载-->
                                    <!-- <el-form-item> -->
                                        <!-- 导入模板下载 -->
                                        <el-button v-permission="{menuCode:menuCode,resourceCode:'downloadTemplate'}" type="primary" @click="downloadTemplate('downloadTemplate')" icon="el-icon-download" :loading="loading">{{ $t('playManage.btnText.downloadTemplate') }}</el-button>
                                    <!-- </el-form-item> -->
                                    <!-- <el-form-item> -->
                                        <!-- 导出 -->
                                        <el-button v-permission="{menuCode:menuCode,resourceCode:'exportBtnText'}" type="primary" @click="onExport('exportBtnText')" icon="el-icon-download" :loading="loading">{{ $t('tagManage.btnText.exportBtnText') }}</el-button>
                                    <!-- </el-form-item> -->
                                    <!-- <el-form-item> -->
                                        <!-- 重置 -->
                                        <el-button v-permission="{menuCode:menuCode,resourceCode:'resetBtnText'}" type="primary" @click="onReset('form')">{{ $t('btnText.resetBtnText') }}</el-button>
                                    <!-- </el-form-item> -->
                                    <!-- <el-form-item> -->
                                        <!-- 查询 -->
                                        <el-button v-permission="{menuCode:menuCode,resourceCode:'queryBtnText'}" type="primary" @click="onQuery('queryBtnText')" icon="el-icon-search" :loading="loading">{{ $t('btnText.queryBtnText') }}</el-button>
                                    </el-form-item>
                                </div>
                             </el-col>

                         </el-row>
                    
                    
                    
                    
                </el-form>
            </div>
            <div class="dataBox" ref="dataBox">

                <transition enter-active-class="animated zoomIn" leave-active-class="animated rotateOut">
                    <el-table v-if="isInit" ref="singleTable"
                                :data="tableData"
                                :height="tableHeight"
                                @sort-change="sortChange"
                                v-loading="loading" size="mini"
                                style="width: 100%;" stripe=stripe border=border>
                         <!--复选框-->
                        <el-table-column type="index"  width="50" fixed="left"
                                            :label="$t('table.xh')" align="center">
                                            </el-table-column>
                        <el-table-column :label="$t('table.op')" fixed="left" min-width="240">
                            <template slot-scope="scope">

                                <el-button v-permission="{menuCode:menuCode,resourceCode:'editBtnText'}" size="gv" icon="el-icon-edit" :loading="loading" @click="edit(scope.$index, scope.row,'editBtnText')"
                                            >{{ $t('btnText.editBtnText') }}</el-button>
                                <!--下发-->
                                <el-button size="gv" icon="el-icon-delete" :disabled="scope.row.sendtoState!='StayDown'"
                                    v-permission="{menuCode: menuCode, resourceCode: 'sendBtnText'}"
                                        type="danger" :loading="loading" @click="onSend(scope.$index, scope.row,'sendBtnText')"
                                      >{{ $t('ParentAssetIssuance.btnText.sendBtnText') }}</el-button>
                                <!-- 恢复 -->
                                <el-button size="gv" icon="el-icon-delete" v-show="scope.row.isEnable==='Invalid'"
                                v-permission="{menuCode: menuCode,resourceCode: 'recoveryBtnText'}"
                                      type="danger" :loading="loading" @click="revertLogoffRow(scope.$index, scope.row,'recoveryBtnText')"
                                     >{{ $t('btnText.recoveryBtnText') }}</el-button>
                                <!-- 注销 -->
                                <el-button v-permission="{menuCode:menuCode,resourceCode:'passBtnText'}" size="gv" icon="el-icon-delete"
                                            type="danger" :loading="loading" @click="logoffRow(scope.$index, scope.row,'passBtnText')"
                                            v-show="scope.row.isEnable=='Available'"
                                            >{{ $t('btnText.logoffBtnText') }}</el-button>
                                <!-- 删除 -->
                                <el-button v-permission="{menuCode: menuCode,resourceCode: 'deleteBtnText'}"
                                size="gv" icon="el-icon-delete"
                                v-show="scope.row.isEnable=='Invalid'" type="danger"
                                :loading="loading" @click="deleteRow(scope.$index, scope.row,'deleteBtnText')" >
                                {{ $t('btnText.deleteBtnText') }}</el-button>
                            </template>
                        </el-table-column>
                        <el-table-column prop="tagName" min-width="180" fixed="left"
                                            :label="$t('tagManage.tableText.tagName')" sortable="custom" sort-by="TagName">
                        </el-table-column>
                        <el-table-column prop="assetNum" min-width="110" fixed="left"
                                            :label="$t('tagManage.tableText.assetsNum')" sortable="custom" sort-by="assetNum">
                        </el-table-column>
                        <el-table-column prop="state" min-width="130"
                        :label="$t('tagManage.tableText.status')" sortable="custom" sort-by="state">
                        </el-table-column>
                        <!--下发状态-->
                    <el-table-column prop="sendtoStateName" min-width="110"
                                        :label="$t('ParentAssetIssuance.table.ParentAssetIssuance.status')" sortable="custom" sort-by="sendtoState">
                    </el-table-column>
                        <el-table-column prop="createdDateConversion" min-width="180"
                        :label="$t('tagManage.tableText.createTime')" sortable="custom" sort-by="createdDate">
                        </el-table-column>
                        <el-table-column :label="$t('tagManage.tableText.lastUpdateBy')" min-width="120" sortable="custom" prop="modifier" sort-by="modifier">
                        </el-table-column>
                        <el-table-column :label="$t('tagManage.tableText.lastUpdateTime')" min-width="180" sortable="custom" prop="lastUpdatedDateConversion" sort-by="lastUpdatedDate">
                        </el-table-column>

                    </el-table>
                </transition>

            </div>
        </div>
        <div class="pageBox">
            <el-pagination @size-change="sizeChange"
                            @current-change="currentPageChange"
                            :current-page="pager.curPage"
                            :page-sizes="pager.sizes"
                            :page-size="pager.curSize"
                            :background="true"
                            layout="total, sizes, prev, pager, next, jumper" :total="pager.total">
            </el-pagination>
        </div>

        <!--编辑对话框-->
        <transition enter-active-class="animated rotateIn" leave-active-class="animated rotateOut">
            <el-dialog :title="$t('label.dialogTitle')" :visible.sync="isShowEditForm" top="5vh" :close-on-click-modal="false" >
                <el-form :model="editForm" ref="editForm" size="mini"
                        :label-position="editFormPosition" status-icon=status-icon :rules="editRules">
                        <el-input v-model.trim="editForm.keyId"  v-show="false"></el-input>
                    <el-form-item :label="$t('tagManage.editLabel.tagName')" :label-width="editformLabelWidth" prop="tagName">
                        <el-input v-model.trim="editForm.tagName" maxlength="20"
                                :placeholder="$t('tagManage.editLabel.placeholderTagName')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('tagManage.editLabel.tagCode')" :label-width="editformLabelWidth" prop="tagCode">
                        <el-input v-model.trim="editForm.tagCode" maxlength="20"
                                :placeholder="$t('tagManage.editLabel.placeholderTagCode')"></el-input>
                    </el-form-item>

                    <el-form-item :label="$t('tagManage.editLabel.status')"   :label-width="editformLabelWidth" prop="state">
                        <el-select v-model.trim="editForm.state" >
                          <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText" v-for="drug in enables"></el-option>
                          <!-- <el-option :label="$t('tagManage.label.online')" value="Online"></el-option>
                          <el-option :label="$t('tagManage.label.offline')" value="Offline"></el-option> -->
                        </el-select>
                    </el-form-item>
                </el-form>
                <div slot="footer">
                    <el-button size="mini" @click="isShowEditForm = false" :loading="loading">{{ $t('btnText.cancelBtnText') }}</el-button>
                    <el-button size="mini" type="primary" @click="submitForm('editForm',currentResCode)" :loading="loading">{{ $t('btnText.saveBtnText') }}</el-button>
                </div>
            </el-dialog>
        </transition>

    <el-dialog title="导入" width="400px" :visible.sync="dlgUploadVisible" :close-on-click-modal="false">
      <upload-file
        v-bind:uploadUrl="uploadCourseMaterialUrl"
        v-bind:acceptFileType="'.xlsx'"
        v-bind:uploadParams="uploadCourseMaterialParams"
        v-bind:fileList="fileList"
        v-bind:autoUpload="false"
        v-bind:fileLimit="1"
        v-bind:selectName="'选取文件'"
        v-bind:uploadBtn="'提交'"
        v-bind:fileTypeText="'xlsx'"
        v-bind:submitSuccess="submitUploadSuccess"
        v-bind:menuCode="menuCode"
      ></upload-file>
    </el-dialog>
  </div>
</template>

<script>

import comBaseVue from '../../baseViewModel';
import { futimes } from 'fs';

export default {
  mixins: [comBaseVue],
  name:'TagManage',
  components: {
    'upload-file': () => import('../common/UploadFile')
  },
  props:{
    menuCode:String
  },
  data () {

    return {
        isInit:false,
        tableHeight:100,
        isShowEditForm2:false,
        sendtoStates:[],
        enables:[],
        isEnables:[],
        appDivStyle:{
            height:this.$store.getters.appHeight,
        },
        modelName:"com.ispr.iptv.entity.media.SysTagEntity",
        // 查询条件
        formQueryCondition: {
            tagName: {

                //mapName: 'code.key',  映射的别名 在同时查询一个属性时需要别名
                //gName:'code',   组名
                key:'tagName',
                op: 'LIKE', // 操作符
                val: '' // 查询的值
            },
            state: {
               op: '=',
               key:'state',
                val: ''
            },
            sendtoState:{
              key:'sendtoState',
              op: '=',
              val:''
            },
            isEnable:{
              key:'isEnable',
              op: '=',
              val:'Available'
            }
        },
        // 编辑面板绑定的对象
        editForm: {
            keyId: 0,
            version: 0,
            tagName:"",
            // assetNum:"",
            tagCode: "",
            state:"",
            sendtoState: "StayDown",
            isEnable:"Available"
        },
        // 编辑面板的验证规则
        editRules: {
            tagName: [{ required: true, message: this.$i18n.t('tagManage.queryLabel.placeholderTagName'), trigger: 'blur' }],
            tagCode: [{ required: true, message: this.$i18n.t('tagManage.queryLabel.placeholderTagCode'), trigger: 'blur' }],
        },

        //////////////////////////////////文件导入/////////////////////
        uploadCourseMaterialUrl: '/api/import/upload',
        uploadCourseMaterialParams: null,
        dlgUploadVisible: false,
        sendType:"",
        singleSend:{},
        fileList: [],

    }
  },
  methods:{

     // 重置
    onReset:function(){
        if (this.$refs['form']) {
            this.$refs['form'].resetFields();
        }
        this.formQueryCondition.tagName.val = "";
        this.formQueryCondition.state.val = "";
        this.formQueryCondition.sendtoState.val = "";
        this.formQueryCondition.isEnable.val = "Available";
        // this.formQueryCondition.sort.val = "";
    },
    // 注销按钮
        logoffRow: function(index, row, rescode) {
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            var _this = this;
            this.$confirm(this.$i18n.t("message.confirmlogoffMessage"),
                this.$i18n.t("message.confirmTitle"), {
                confirmButtonText: this.$i18n.t("message.yes"),
                cancelButtonText: this.$i18n.t("message.cancel"),
                type: "warning",
                callback: function (action, instance) {
                    if (action == "confirm") {
                        var commandBody = {  "keyId": row.keyId, "version": row.version, isEnable: "Invalid", sendtoState:"StayDown" };
                        _this.loading = true;
                        _this.procCommand("PassProc",//PartialUpdateProc
                                _this.modelName,
                                "N",
                                commandBody,
                                null,
                                _this.submitFormCallback);
                    }
                    
                }
            });
        },
        // 恢复注销按钮
        revertLogoffRow: function(index, row, rescode) {
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            var _this = this;
            this.$confirm(this.$i18n.t("message.confirmNormalMessage"),
                this.$i18n.t("message.confirmTitle"), {
                confirmButtonText: this.$i18n.t("message.yes"),
                cancelButtonText: this.$i18n.t("message.cancel"),
                type: "warning",
                callback: function (action, instance) {
                    if (action == "confirm") {
                        var commandBody = {  "keyId": row.keyId, "version": row.version, isEnable: "Available", sendtoState:"StayDown" };
                        _this.loading = true;
                        _this.procCommand("RecoveryProc",//PartialUpdateProc
                                _this.modelName,
                                "N",
                                commandBody,
                                null,
                                _this.submitFormCallback);
                    }
                    
                }
            });
        },
    // 新增
    onNew: function(rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        this.isShowEditForm = true;
        if (this.$refs['editForm']) {
            this.$refs['editForm'].resetFields();
        }
        this.editForm.keyId = "";
        this.editForm.version = "";
        this.editForm.tagName = "";
        this.editForm.tagCode = "";
        // this.editForm.assetNum = "";
        this.editForm.sendtoState = "StayDown";
        this.editForm.state = "Online";
        this.curCommand = "TagSaveProc";
        this.canEditCode = false;
    },

    //编辑面板提交后调用，设置唯一性验证条件
    setEditFormCheck:function setEditFormCheck(){
        if(this.curCommand == "TagSaveProc"){
            this.editFormCheck = [{
                    key: 'tagCode',
                    op: '=', // 操作符
                    val: this.editForm.tagCode// 查询的值
                },{
                    key: 'isEnable',
                    op: '=', // 操作符
                    val: 'Available'
                }];
        }else if(this.curCommand == "TagUpdateProc"){
            this.editFormCheck = [{
                    key: 'tagCode',
                    op: '=', // 操作符
                    val: this.editForm.tagCode// 查询的值
                },{
                    key: 'isEnable',
                    op: '=', // 操作符
                    val: 'Available'
                },{
                    key: 'keyId',
                    op: '<>', // 操作符
                    val: this.editForm.keyId
                }];
        }

    },

    // 编辑按钮回调事件
    editCallback: function(isSuccess,json) {
        if(isSuccess){
            this.curCommand = "TagUpdateProc";
            this.isShowEditForm = true;
            if (this.$refs['editForm']) {
                this.$refs['editForm'].resetFields();
            }
            this.editForm.keyId = json.keyId;
            this.editForm.version = json.version;
            this.editForm.tagName = json.tagName;
            this.editForm.tagCode = json.tagCode;
            this.editForm.state = json.state;
            this.editForm.sendtoState = "StayDown";
            // this.canEditCode = true;
        }
        else{
            this.$message({
                message: json.msg,
                type: 'warning'
                });
        }
    },
    //单个下发
    onSend: function(index, row, rescode) {
        var _this = this;
        this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        this.sendType = "single";
        this.singleSend = {};
        let data = {
          "keyId":row.keyId,
          "version":row.version,
          "resType":"TAG",
        };
        let dataList = [];//最终传给后台的总数据
        dataList.push(data);
        this.$confirm(this.$i18n.t("message.confirmSendMessage"),
            this.$i18n.t("message.confirmTitle"), {
            confirmButtonText: this.$i18n.t("message.yes"),
            cancelButtonText: this.$i18n.t("message.cancel"),
            type: "warning",
            callback: function (action, instance) {
                if (action == "confirm") {
                    _this.loading = true;
                    _this.procCommand("MediaSendToProc",
                    _this.modelName,
                    "Default",
                    {
                      "dataList":dataList,
                    },
                    null,
                    _this.submitFormCallback);
                }
            }
        });
    },



    // // 批量下发
    // onBatchRelease: function(){
    //     this.isShowEditForm2 = true;
    // },
    //  // 提交编辑面板数据
    //     submitForm2: function submitForm2(formName) {
    //         var _this = this;

    //         this.$refs[formName].validate(function (valid) {
    //             if (valid) {
    //                 _this.loading = true;
    //                 _this.procCommand(_this.curCommand,
    //                 _this.modelName,
    //                 "Default",
    //                 _this.editForm,
    //                 _this.submitForm2Callback);
    //             } else {
    //                 return false;
    //             }
    //         });
    //     },
    //     // 执行命令后的回调函数
    //     submitForm2Callback: function submitForm2Callback(isSuccess,json) {
    //         this.loading = false;
    //         if(isSuccess){
    //             this.isShowEditForm2 = false;
    //             this.$message({
    //                 message: this.$i18n.t("message.successTip"),//resource.message.successTip,
    //                 type: 'success'
    //             });
    //             this.queryTable();
    //         }
    //         else
    //         {
    //             this.$message({
    //                             message: this.$i18n.t("errorCode." + json.reason),
    //                             type: 'warning'
    //                             });
    //         }
    //     },

     /////下载导入模板
    downloadTemplate: function downloadTemplate (rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      this.downloadByIdOrName(this, '/import/downtemplate', 'fileName', '标签信息导入模板.xlsx', '标签信息导入模板.xlsx');
    },

     /////////////////////////////////// 频道信息导入 ///////////////////////////////////////////
    // 打开导入资材关系的dialog
    openUploadDlg: function openUploadDlg (rescode) {
       this.currentResCode = (rescode && rescode!=='') ? rescode : '';
       let _this = this;
      // this.$alert('注意：导入后将会覆盖原有的所有数据，是否继续？', '提示', {
      //   confirmButtonText: '确定',
      //   callback: action => {
      //     if (action === 'confirm') {
            // 初始化错误文件下载id
            _this.errorTaskId = null;
            // 清空文件列表
            _this.fileList = [];
            _this.dlgUploadVisible = true;
            // this.uploadPhorderUrl = this.baseUrl+'/import/upload';
            _this.uploadCourseMaterialParams = {'className': _this.modelName};
      //     }
      //   }
      // });
    },
    // 查询按钮
        onQuery: function(rescode) {
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            this.pager.curPage = 1;
            this.queryTable();
        },

          // 查询网格数据
        queryTable: function() {
            // this.curCommand = "ProductOrderStatistics";

            this.loading = true;
            this.auditConfirmQuery("/api/sysTag/select",this.modelName, "Query", this.formQueryCondition, this.pager,this.sort, this.submitFormEditCallback);
        },

        // 执行命令后的回调函数
        submitFormEditCallback: function submitFormEditCallback(isSuccess,json) {

            this.loading = false;
              try{
                if (isSuccess) {
                    //alert(JSON.stringify(json));
                    this.pager.total = json.total;
                    this.temp = "true";
                    this.tableData = [];
                    for (var i = 0; i < json.list.length; i++) {
                        this.tableData.push(json.list[i]);
                    }

                }
                else {
                    this.$message.error(json.msg);
                }
            }
            catch(e){
                alert(e);
            }
        },

    submitUploadSuccess: function submitUploadSuccess (response, file, fileList) {
      if (response.code === 'SUCCESS') {
        if (response.data.status === '0') {
          this.dlgUploadVisible = false;
          this.$message.success('导入成功');
          this.fileList = []; // 清空上传文件列表
          // 刷新表格数据
          this.onQuery();
          return false;
        }
        if (response.data.status === '3') {
          let _this = this;
          this.$alert('导入失败，是否下载失败原因文件?', '提示', {
            confirmButtonText: '确定',
            callback: function callback (action) {
              if (action === 'confirm') {
                _this.downloadByIdOrName(_this, '/import/downerr', 'taskId', response.data.taskId, response.data.errFileName);
              } else {
                _this.$message({
                  type: 'info',
                  message: '已取消'
                });
              }
            }
          });
          this.fileList = []; // 清空上传文件列表
          this.dlgUploadVisible = false;
        }
      } else {
        this.$message.error(response.msg);
      }
    },
//////////////////////////////////////////////////////////////////////////////////////////////////

    // 导出
     onExport:function onExport (rescode) {

       this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      let param = {
          'className': 'com.ispr.iptv.entity.media.TemporaryLabelEntity',
          'opKey': 'Export',
          'params': this.queryObjToArray(this.formQueryCondition),
          'sort': [this.sort],
          'fileName': '标签管理'
          };
      let fileName = '标签管理' + '.xlsx';
      this.downloadByIdOrName(this, '/export/exportSysTag', 'param', JSON.stringify(param), fileName);
    },

    //为状态下拉框赋值
    findEnables:function(){
      this.findByTypeCode("10006",this.setEnables);//根据类型编码去取相应的值
    },
    //下拉框值的回调
    setEnables:function(isSuccess,json){
      try{
        if(isSuccess){
          this.enables=[];
          for(var i=0 ; i < json.data.length ; i++){
            this.enables.push(json.data[i]);
          }
        }else{
          this.$message.error(json.msg);
        }
      }catch(e){
        alert(e);
      }
    },

    findSendtoStates:function(){
      this.findByTypeCode("10011",this.setSendtoStates);//根据类型编码去取相应的值
    },
    //下拉框值的回调
    setSendtoStates:function(isSuccess,json){
      try{
        if(isSuccess){
          this.sendtoStates=[];
          for(var i=0 ; i < json.data.length ; i++){
            this.sendtoStates.push(json.data[i]);
          }
        }else{
          this.$message.error(json.msg);
        }
      }catch(e){
        alert(e);
      }
    },

    findIsEnable:function(){
      this.findByTypeCode("10001",this.setIsEnable);//根据类型编码去取相应的值
    },
    //下拉框值的回调
    setIsEnable:function(isSuccess,json){
      try{
        if(isSuccess){
          this.isEnables=[];
          for(var i=0 ; i < json.data.length ; i++){
            this.isEnables.push(json.data[i]);
          }
        }else{
          this.$message.error(json.msg);
        }
      }catch(e){
        alert(e);
      }
    },
    enterDown(){
      var g = this
      if(g.isShowEditForm){
        g.submitForm('editForm',g.currentResCode)
      }else if(!g.loading){
        g.onQuery()
      }
    }
  },
  mounted: function mounted() {
    this.findSendtoStates();
    this.findEnables();
    this.findIsEnable();
    this.tableHeight = this.$refs.context.offsetHeight - this.$refs.queryBox.offsetHeight;
    this.isInit = true;
    this.onQuery();

  }
}


</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
